//
//  LYDPopViewController1.m
//  HAODE
//
//  Created by LiYinDi on 16/3/18.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "LYDPopViewController1.h"
#import "UIImageView+WebCache.h"

#import "SpecColorDataModel.h"
#import "SpecSizeDataModel.h"
#import "FMDB.h"
#import "PlaceOrderSpecTableViewCell.h"
#import "specTableViewDataModel.h"
#import "HasSpecFmdbModel.h"
#import "HasSpecFmdbTool.h"
#import "UIViewExt.h"

@interface LYDPopViewController1 ()<PlaceOrderSpecCellDelegate>
{
    NSMutableArray *modelArray;
    NSString *colorSpecID;
    NSString *sizeSpecID;
    NSString *specName;
    NSString *userToken;
    NSString *specPrice;
    NSString *specInv;
    NSString *shopCartQty;
    NSString *specID;
    NSInteger subCellTag;
    NSInteger tagIndex;
    NSInteger colorIndex;
    NSInteger sizeIndex;
    NSMutableArray *specTableViewModelArray;
    CGFloat keyBoardHeight;
    
    NSInteger goodDetailClickCount;
}
@property(nonatomic,strong)FMDatabase *db;
@end

@implementation LYDPopViewController1
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setAutoLayout];

    modelArray=[NSMutableArray array];
    specTableViewModelArray=[NSMutableArray array];
    colorSpecID=@"";
    sizeSpecID=@"";
    specName=@"";
    userToken=@"";
    specPrice=@"";
    specInv=@"";
    specID=@"";
    shopCartQty=@"";
    tagIndex=0;
    goodDetailClickCount=0;
     [_topAlphaBtn setBackgroundColor: [Global parseColor:@"#66000000"]];
    
    [_productImageView setImageWithURL:[NSURL URLWithString:_productURL] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
    _productImageView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _productImageView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
     _productImageView.layer.borderWidth= 0.5f;
    
     _productNameLabel.text=_productNameStr;

    modelArray=[NSMutableArray array];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    userToken=Token;
//  [Global showIndeterminateHud:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
    [params setObject:userToken forKey:@"tokenId"];
    [params setObject:_itemId forKey:@"itemId"];
    [params setObject:@"Y" forKey:@"isShopCart"];
    [HttpRequest requestData:@"Product/GetProductDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
       NSLog(@"GetProductDetail====%@",severDataDict.dataDict);
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
                [Global hideProgressHUDInternal:self.view];
               
                NSArray *dataArray=severDataDict.dataDict[@"itemColours"];
                for (NSDictionary *dic in dataArray) {
                    SpecColorDataModel *dataModel=[SpecColorDataModel dataModelWithDict:dic];
                    [modelArray addObject:dataModel];
                    
                }

                [self setColor];
               
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
                
                
            }
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
    }];
    
//    [_confirmBtn addTarget:self action:@selector(confirmBtn:) forControlEvents:UIControlEventTouchUpInside];
}

//-(void)confirmBtn:(UIButton*)sender{
//
//
//
//}
-(void)setColor
{
    for (UIView *v in _colorView.subviews ) {
        [v removeFromSuperview];
    }
    
    UILabel *colorTag=[[UILabel alloc] initWithFrame:CGRectMake(16, 20, 100, 14)];
    colorTag.text=@"颜色";
    colorTag.tag=1000;
    [colorTag setFont:[UIFont systemFontOfSize:14]];
    colorTag.textColor=[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0f];
    [_colorView addSubview:colorTag];
    
    UIImageView *lineImageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 44,ScreenWidth-20 , 1)];
    lineImageView.tag=1000;
    [lineImageView setImage:[UIImage imageNamed:@"hengxian.png"] ];
    [_colorView addSubview:lineImageView];

    for (int i=0; i<modelArray.count; i++) {
        SpecColorDataModel *dataModel=modelArray[i];
        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
        CGRect rect=button.frame;
        rect.size.height=33;
        rect.size.width=(ScreenWidth-48)/3;
        rect.origin.x=13+((ScreenWidth-48)/3)*(i%3)+(i%3)*11;
        rect.origin.y=56+40*(i/3);
        button.frame=rect;
        button.tag=i;
        [button setBackgroundColor:[UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]];
        
        
        button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
        [button setTitle:dataModel.colourName forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        
        if (i==tagIndex) {
             [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor colorWithRed:90.0f/255.0f green:130.0f/255.0f blue:26.0f/255.0f alpha:1.0]];
            colorSpecID=dataModel.colourId;
            specName=dataModel.colourName;
            specInv=dataModel.specInv;
            specPrice=dataModel.specPrice;
            specID=dataModel.specId;
            _priceLabel.text=[NSString stringWithFormat:@"¥ %@",specPrice];
            
            shopCartQty=dataModel.shopCartQty;
            NSString *str=[NSString stringWithFormat:@"库存 %@",specInv];
            NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
            [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
            
            _stockLabel.attributedText=attriString;

            
        }
        
        [button addTarget:self action:@selector(colorButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [_colorView addSubview:button];
        
 
        if (i==modelArray.count-1) {
            
           CGFloat height=button.frame.origin.y+button.frame.size.height+11;
            
            
            [_colorView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(_specScrollContentView.mas_top);
                make.bottom.equalTo(_specScrollContentView.mas_top).with.offset(height);
                make.left.equalTo(_specScrollContentView.mas_left);
                make.right.equalTo(_specScrollContentView.mas_right);
                
            }];
            
            [self setSize:0];
        }
        
        
    }
}
-(void)colorButtonClick:(UIButton *)sender
{
    for (UIButton *btn in _colorView.subviews ) {
        if (btn.tag!=1000) {
            
        
         [btn setBackgroundColor:[UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0]];
        [btn setTitleColor:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        }
    }
    [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [sender setBackgroundColor:[UIColor colorWithRed:90.0f/255.0f green:130.0f/255.0f blue:26.0f/255.0f alpha:1.0]];
     SpecColorDataModel *colorModel=modelArray[sender.tag];
    colorIndex=sender.tag;
    colorSpecID=colorModel.colourId;
    specName=colorModel.colourName;
    specID=colorModel.specId;
     specInv=colorModel.specInv;
    specPrice=colorModel.specPrice;
     shopCartQty=colorModel.shopCartQty;
    _priceLabel.text=[NSString stringWithFormat:@"¥ %@",specPrice];
//    NSLog(@"colorModel.specInv==%@",colorModel.specInv);
//    NSLog(@"specInv pp==%@",specInv);
    if (colorModel.sizeModelArray.count>0) {
//       NSLog(@"olorModel.sizeModelArraypp==%@",colorModel.sizeModelArray);
    SpecSizeDataModel *sizeModel=colorModel.sizeModelArray[0];
    sizeSpecID=sizeModel.sizeId;
    specName=[NSString stringWithFormat:@"%@%@",specName,sizeModel.sizeName];
    specInv=sizeModel.specInv;
    specPrice=sizeModel.specPrice;
    shopCartQty=colorModel.shopCartQty;
    _priceLabel.text=[NSString stringWithFormat:@"¥ %@",specPrice];
    specID=sizeModel.specId;
    [self setSize:sender.tag];
    }
    tagIndex=sender.tag;
    NSLog(@"%ld",sender.tag);
    NSString *str=[NSString stringWithFormat:@"库存 %@",specInv];
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
    [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
    
    _stockLabel.attributedText=attriString;
    

}

-(void)setSize:(NSInteger)senderTag
{
    for (UIView *v in _sizeView.subviews ) {
        [v removeFromSuperview];
    }
    SpecColorDataModel *colorModel=modelArray[senderTag];
    
    NSMutableArray   *sizeModelArray=colorModel.sizeModelArray ;
    
//    NSLog(@"sizeModelArraymmmmm====%@",sizeModelArray);
    if (sizeModelArray.count>0) {
        
   
    UILabel *colorTag=[[UILabel alloc] initWithFrame:CGRectMake(16, 0+24, 100, 14)];
    colorTag.tag=1000;
    colorTag.text=@"尺码";
    [colorTag setFont:[UIFont systemFontOfSize:14]];
    colorTag.textColor=[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0f];
    [_sizeView addSubview:colorTag];
    
    UIImageView *lineImageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 24+24, ScreenWidth-20, 1)];
      lineImageView.tag=1000;
    [lineImageView setImage:[UIImage imageNamed:@"hengxian.png"] ];
    [_sizeView addSubview:lineImageView];
    
  
    for (int i=0; i<sizeModelArray.count; i++) {
        SpecSizeDataModel *sizeModel=sizeModelArray[i];
        
        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
        CGRect rect=button.frame;
        rect.size.height=32;
        
        rect.size.width=(ScreenWidth-59)/4;
        rect.origin.x=13+((ScreenWidth-59)/4)*(i%4)+(i%4)*10;
//        rect.size.width=ScreenWidth/4.5;
//        rect.origin.x=10+(ScreenWidth/4.2)*(i%4);
        rect.origin.y=36+24+40*(i/4);
        button.frame=rect;
        button.tag=i;
        [button setBackgroundColor:[UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]];
       
        
        button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
        [button setTitle:sizeModel.sizeName forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        
        [button addTarget:self action:@selector(sizeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [_sizeView addSubview:button];
        
        if (i==0) {
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor colorWithRed:90.0f/255.0f green:130.0f/255.0f blue:26.0f/255.0f alpha:1.0]];
            sizeSpecID=sizeModel.sizeId;
            specName=[NSString stringWithFormat:@"%@%@",colorModel.colourName,sizeModel.sizeName];
            specInv=sizeModel.specInv;
            specPrice=sizeModel.specPrice;
            shopCartQty=sizeModel.shopCartQty;
            if (colorModel.specId.length>0 ) {
                specID=colorModel.specId;
            }
            else
            {
                specID=sizeModel.specId;
            }
            
            _priceLabel.text=[NSString stringWithFormat:@"¥ %@",specPrice];
            
            NSString *str=[NSString stringWithFormat:@"库存 %@",specInv];
            NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
            [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
            
            _stockLabel.attributedText=attriString;

        }

        if (i==sizeModelArray.count-1) {
            
           CGFloat height=button.frame.origin.y+button.frame.size.height+11;
            [_sizeView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(_colorView.mas_bottom);
                make.bottom.equalTo(_colorView.mas_bottom).with.offset(height);
                make.left.equalTo(_specScrollContentView.mas_left);
                make.right.equalTo(_specScrollContentView.mas_right);
                
            }];

        }
        }
    }
}
-(void)sizeButtonClick:(UIButton *)sender
{
    sizeIndex=sender.tag;
    for (UIButton *btn in _sizeView.subviews ) {
        if (btn.tag!=1000) {
         [btn setBackgroundColor:[UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]];
         [btn setTitleColor:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        }
    }
    [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [sender setBackgroundColor:[UIColor colorWithRed:90.0f/255.0f green:130.0f/255.0f blue:26.0f/255.0f alpha:1.0]];
     SpecColorDataModel *colorModel=modelArray[colorIndex];
//    NSLog(@"colorModel.sizeModelArray==%@",colorModel.sizeModelArray);
    SpecSizeDataModel *sizeModel=colorModel.sizeModelArray[sender.tag];
    sizeSpecID=sizeModel.sizeId;
    specName=[NSString stringWithFormat:@"%@%@",colorModel.colourName,sizeModel.sizeName];
    specInv=sizeModel.specInv;
    specPrice=sizeModel.specPrice;
    shopCartQty=sizeModel.shopCartQty;
    if (colorModel.specId.length>0 ) {
        specID=colorModel.specId;
    }
    else
    {
        specID=sizeModel.specId;
    }
    _priceLabel.text= [NSString stringWithFormat:@"¥ %@",specPrice];
    NSString *str=[NSString stringWithFormat:@"库存 %@",specInv];
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
    [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
    
    _stockLabel.attributedText=attriString;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return specTableViewModelArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * const  ResultTableViewCellIdentifier = @"PlaceOrderSpecTableViewCell";
    PlaceOrderSpecTableViewCell *cell=( PlaceOrderSpecTableViewCell *)[tableView dequeueReusableCellWithIdentifier: ResultTableViewCellIdentifier];
    if (cell==nil) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"PlaceOrderSpecTableViewCell" owner:self options:nil];
        cell = [array objectAtIndex:0];
    }
  
    cell.delegate=self;
    cell.addCountBtn.tag=indexPath.row;
    cell.subtractCountBtn.tag=indexPath.row;
    //  cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame] ;
    cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
    
     if ([_typeString isEqualToString:@"SCANCASHIER"]) {
         specTableViewDataModel *model=specTableViewModelArray[indexPath.row];
        cell.nameLabel.text= model.specName;
         
         cell.contentLabel.text=[NSString stringWithFormat:@"¥%0.02f  库存 %d",[model.specPrice floatValue],[model.specInv intValue]];
         cell.countTextField.text=[NSString stringWithFormat:@" %d", [model.shopCartQty intValue]];
     }else{
    specTableViewDataModel *model=specTableViewModelArray[indexPath.row];
   
    cell.nameLabel.text= model.specName;
    cell.contentLabel.text=[NSString stringWithFormat:@"¥%0.02f  库存 %d",[model.specPrice floatValue],[model.specStock intValue]];
    cell.countTextField.text=[NSString stringWithFormat:@" %d", [model.specCount intValue]];
     }
    
    return cell;
}
- (IBAction)alphaBtnClick:(id)sender {

    
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
    [params setObject:userToken forKey:@"tokenId"];
    [params setObject:_shopCartId forKey:@"shopCartId"];
    [params setObject:_planId forKey:@"planId"];
    [params setObject:_pid forKey:@"pid"];
    [params setObject:_itemId forKey:@"itemId"];
    [params setObject:specID forKey:@"specId"];
    NSLog(@"params====%@",params);
    [HttpRequest requestData:@"Business/ShopCart/Gifts" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        NSLog(@"GetProductDetail====%@",severDataDict.dataDict);
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
                [Global hideProgressHUDInternal:self.view];
                [_delegate update:severDataDict.dataDict];
                [self dismiss];
                
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
                
                
            }
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
    }];

    
    
    
    
   
}
- (void)show
{
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    self.view.frame = CGRectMake(0,
                                  0,
                                  [UIScreen mainScreen].bounds.size.width,
                                  [UIScreen mainScreen].bounds.size.height);
    
   [window addSubview:self.view];
}
- (void)dismiss
{
    [self.view removeFromSuperview];
    [self removeFromParentViewController];
    
}

-(void)setAutoLayout
{
    [_confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@48);
        
    }];
    
    [_topAlphaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@74);
        
    }];
    [_cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_topAlphaBtn.mas_bottom);
        make.width.equalTo(@80);
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@40);
        
    }];
    [_parentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_topAlphaBtn.mas_bottom);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.bottom.equalTo(self.view.mas_bottom);
        
    }];
    
    [_productImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_parentView.mas_top).with.offset(24);
        make.left.equalTo(_parentView.mas_left).with.offset(10);
        make.width.equalTo(@82);
        make.height.equalTo(@82);
        
    }];
    [_countBackGroundLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_productImageView.mas_bottom) ;
        make.left.equalTo(_productImageView.mas_left) ;
        make.right.equalTo(_productImageView.mas_right) ;
        make.height.equalTo(@15);
        
    }];
    [_xLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_productImageView.mas_bottom) ;
        make.left.equalTo(_productImageView.mas_left).with.offset(5) ;
        make.width.equalTo(@10);
        make.height.equalTo(@15);
        
    }];
    [_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_productImageView.mas_bottom) ;
        make.right.equalTo(_productImageView.mas_right)  ;
        make.left.equalTo(_xLabel.mas_right).with.offset(2) ;
        make.height.equalTo(@15);
        
    }];
    
    
    
    [_productNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_productImageView.mas_top).with.offset(5) ;
        make.left.equalTo(_productImageView.mas_right).with.offset(12);
        make.right.equalTo(self.view.mas_right);
        make.bottom.equalTo(_priceLabel.mas_top).with.offset(-2);
        
    }];
    
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_productNameLabel.mas_bottom).with.offset(2) ;
        make.left.equalTo(_productNameLabel.mas_left) ;
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@13);
        
    }];
    [_stockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_productImageView.mas_bottom).with.offset(-5) ;
        make.left.equalTo(_productNameLabel.mas_left) ;
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@18);
        
    }];
    
    [_productImageBottomLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_productImageView.mas_bottom).with.offset(20);
        make.left.equalTo(_parentView.mas_left).with.offset(10);
        make.right.equalTo(_parentView.mas_right).with.offset(-10);
        make.height.equalTo(@0.5);
        
    }];
    
    [_specParentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_productImageBottomLineLabel.mas_bottom)  ;
        make.left.equalTo(_parentView.mas_left);
        make.right.equalTo(_parentView.mas_right);
        make.bottom.equalTo(_confirmBtn.mas_top);
    }];
    
    
    [_specScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_specParentView.mas_top)  ;
        make.left.equalTo(_specParentView.mas_left);
        make.right.equalTo(_specParentView.mas_right);
        make.bottom.equalTo(_specParentView.mas_bottom ) ;
    }];
    
    
    [_specScrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(_specScrollView);
        make.width.equalTo(_specScrollView);
    }];
    [_colorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0);
        make.left.equalTo(_specScrollContentView.mas_left);
        make.right.equalTo(_specScrollContentView.mas_right);
        make.top.equalTo(_specScrollContentView.mas_top);
    }];
    [_sizeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0);
        make.left.equalTo(_specScrollContentView.mas_left);
        make.right.equalTo(_specScrollContentView.mas_right);
        make.top.equalTo(_colorView.mas_bottom);
    }];
    [_countParentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@67);
        make.left.equalTo(_specScrollContentView.mas_left);
        make.right.equalTo(_specScrollContentView.mas_right);
        make.top.equalTo(_sizeView.mas_bottom);
        make.bottom.equalTo(_specScrollContentView.mas_bottom);
    }];

    
    [_specScrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_countParentView.mas_bottom);
    }];
    
    [_selectedGoodDetailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@44);
        make.left.equalTo(_specParentView.mas_left);
        make.right.equalTo(_specParentView.mas_right);
        make.top.equalTo(_specScrollContentView.mas_bottom);
        
    }];

    
    [_specTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0);
        make.left.equalTo(_specParentView.mas_left);
        make.right.equalTo(_specParentView.mas_right);
        make.top.equalTo(_specParentView.mas_bottom);
    }];
    



}
@end
